package com.example.Words.room.presenter;

import android.app.Application;

import androidx.lifecycle.LiveData;

import com.example.Words.room.model.RoomModeIIntf;
import com.example.Words.room.model.RoomModelImp;
import com.example.Words.room.model.entity.Word;
import com.example.Words.room.ui.view.RoomIntf;

import java.util.List;

/**
 * <pre>
 *  author:huletian
 *  time    :2020/2/22
 *  desc    :表示层实现，调用模型层应用来对数据库进行操作
 *  version:1.0
 * </pre>
 */
public class RoomPresenterImp implements RoomPresenterIntf {
    private RoomModeIIntf model;
    private RoomIntf view;

    public RoomPresenterImp(RoomIntf view, Application application) {
        this.view = view;
        model = new RoomModelImp(application);
    }

    @Override
    public void insertDate(Word... words) {
        model.insertDate(words);
    }

    @Override
    public void clearDate() {
        model.clearDate();
    }

    @Override
    public LiveData<List<Word>> getAllWordsLive() {
        return model.getAllWordsLive();
    }

    @Override
    public void update(Word... words) {
        model.update(words);
    }

    @Override
    public LiveData<List<Word>> findWordsWithPatten(String patten) {
        return model.findWordsWithPatten(patten);
    }

    @Override
    public void deleteWords(Word... words) {
        model.deleteData(words);
    }
}
